  //
//  WorkDetailsViewController.m
//  MagicZhao
//
//  Created by hy002 on 2017/12/22.
//  Copyright © 2017年 HUAYU. All rights reserved.
//

#import "WorkDetailsViewController.h"
#import "WorkerDetailModel.h"
#import "MachinesModel.h"
#import "WorkGroupsModel.h"
#import "SpotsModel.h"
#import "WorkerModel.h"
#import "EmployerViewController.h"
#import "AppraiseViewController.h"
#import "FeedBackViewController.h"
#import "ShareManager.h"

static NSString *cellPath = @"WorkDetailsCell";
@interface WorkDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UIView *setUpView;
}
@property (nonatomic, strong)UITableView *tableview;
@property (nonatomic, strong)WorkerDetailModel *detailModel;

@end

@implementation WorkDetailsViewController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self requestProjectSelect];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatUI];
    [self requestProjectSelect];
}

- (void)creatUI
{
    self.navigationController.navigationBar.hidden = NO;
    self.navigationItem.title = @"工作详情";
    self.view.backgroundColor = BacksColor;
    self.navigationController.navigationBar.translucent = NO;
    UIImage *searchBtnImage = [[UIImage imageNamed:@"dd"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:searchBtnImage style:UIBarButtonItemStyleDone target:self action:@selector(feedbackAction)];
    self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-STA_NAV_HEIGHT-SCREER_HeiX) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [_tableview setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
    _tableview.backgroundColor = BacksColor;
    [self.view addSubview:_tableview];
    setUpView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-115*displaywidth, 0, 100*displaywidth, 100*displaywidth)];
    setUpView.backgroundColor = [UIColor whiteColor];
    setUpView.layer.cornerRadius = 5;
    setUpView.layer.masksToBounds = YES;
    setUpView.hidden = YES;
    [self.view addSubview:setUpView];
    NSArray *imgUrlAry = @[@"fx",@"jb"];
    NSArray *nameAry = @[@" 分享",@" 举报"];
    for (int i = 0; i < imgUrlAry.count; i++)
    {
        UIButton *btn = [ZCControl createButtonWithFrame:CGRectMake(0, 50*displaywidth*i, 100*displaywidth, 49*displaywidth) ImageName:imgUrlAry[i] Target:self Action:@selector(closeSetUpAction:) Title:nameAry[i] Font:13.0];
        [btn setTitleColor:RGB(77, 77, 77) forState:UIControlStateNormal];
        btn.tag = 80+i;
        [setUpView addSubview:btn];
        if (i != 1)
        {
            UIView *lineAAView = [[UIView alloc] initWithFrame:CGRectMake(0, (i+1)*50*displaywidth-1*displaywidth, 100*displaywidth, 1*displaywidth)];
            lineAAView.backgroundColor = LinesColor;
            [setUpView addSubview:lineAAView];
            
        }
    }
    
}

- (void)feedbackAction
{
    setUpView.hidden = !setUpView.hidden;
    
}

- (void)closeSetUpAction:(UIButton *)btn
{
    if (btn.tag == 80)
    {
        //分享
        ShareManager *shareManager = [ShareManager shareToManager];
        shareManager.title = @"分享项目";
        NSString *url = [LTools cacheForKey:@"loginHeadImg"];
        shareManager.imgUrl = url;
        shareManager.descriptionStr = _detailModel.name;
        shareManager.webUrl = @"http://m.moform.cn/#/";
    }
    else
    {
        //举报
        FeedBackViewController *vc = [[FeedBackViewController alloc] init];
        vc.titleStr = @"举报";
        [self.navigationController pushViewController:vc animated:YES];
    }
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 2;
    }
    if (section == 3)
    {
        if (_detailModel)
        {
            NSArray *spotsAry = _detailModel.spots;
            return spotsAry.count;
        }
        return 0;
    }
    
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellPath];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (_detailModel)
    {
        if (indexPath.section == 0)
        {
            if (indexPath.row == 0)
            {
                UILabel *projectLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 5*displaywidth, SCREEN_WIDTH-100*displaywidth, 40*displaywidth) Font:16.0 Text:_detailModel.name Color:RGB(129, 148, 196)];
                [cell.contentView addSubview:projectLab];
                NSString *timeStr = _detailModel.createDtm;
                if (timeStr.length > 15)
                {
                    timeStr = [timeStr substringToIndex:_detailModel.createDtm.length-3];
                }
                UILabel *timeLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-180*displaywidth, 5*displaywidth, 165*displaywidth, 40*displaywidth) Font:12.0 Text:timeStr Color:RGB(153, 153, 153)];
                timeLab.textAlignment = NSTextAlignmentRight;
                [cell.contentView addSubview:timeLab];
                if (_deatilType == 3)
                {
                    projectLab.frame = CGRectMake(15*displaywidth, 0, SCREEN_WIDTH-100*displaywidth, 35*displaywidth);
                    timeLab.frame = CGRectMake(SCREEN_WIDTH-180*displaywidth, 0, 165*displaywidth, 35*displaywidth);
                    UIImageView *imgAview = [ZCControl createImageViewWithFrame:CGRectMake(15*displaywidth, 40*displaywidth, 20*displaywidth, 20*displaywidth) ImageName:@"gznr"];
                    imgAview.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.contentView addSubview:imgAview];
                    UILabel *nameLab = [ZCControl createLabelWithFrame:CGRectMake(40*displaywidth, 35*displaywidth, SCREEN_WIDTH-160*displaywidth, 30*displaywidth) Font:13.0 Text:_detailModel.categoryName Color:RGB(153, 153, 153)];
                    CGRect bounds = [nameLab.text boundingRectWithSize:CGSizeMake(1000, 30*displaywidth) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:NormalFontWithSize(13.0+fontScale) forKey:NSFontAttributeName] context:nil];
                    CGFloat W = bounds.size.width;
                    if (W > SCREEN_WIDTH-170*displaywidth)
                    {
                        W = SCREEN_WIDTH-170*displaywidth;
                    }
                    nameLab.frame = CGRectMake(40*displaywidth, 35*displaywidth, W+5*displaywidth, 30*displaywidth);
                    [cell.contentView addSubview:nameLab];
                    UIImageView *imgBview = [ZCControl createImageViewWithFrame:CGRectMake(W+60*displaywidth, 40*displaywidth, 20*displaywidth, 20*displaywidth) ImageName:@"xiangmujine"];//xiangmujine
                    imgBview.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.contentView addSubview:imgBview];
                    UILabel *moneyLab = [ZCControl createLabelWithFrame:CGRectMake(W+85*displaywidth, 35*displaywidth, 100*displaywidth, 30*displaywidth) Font:13.0 Text:[NSString stringWithFormat:@"%@",_detailModel.budget] Color:RGB(153, 153, 153)];
                    [cell.contentView addSubview:moneyLab];
                }
            }
            else
            {
                NSString *sfType = @"雇主";
                NSString *name = _detailModel.employer.user.name;
                UIColor *backColor = RGB(238, 103, 94);
                if (_deatilType == 3)
                {
                    sfType = @"厂家";
                    name = _detailModel.contractor.user.name;
                    backColor = ThemeColor;
                }
                UILabel *typeLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 10*displaywidth, 35*displaywidth, 15*displaywidth) Font:10.0 Text:sfType Color:[UIColor whiteColor]];
                typeLab.textAlignment = NSTextAlignmentCenter;
                typeLab.backgroundColor = backColor;
                typeLab.layer.cornerRadius = 2;
                typeLab.layer.masksToBounds = YES;
                [cell.contentView addSubview:typeLab];
                UILabel *titleLabel = [ZCControl createLabelWithFrame:CGRectMake(60*displaywidth, 0, SCREEN_WIDTH- 130*displaywidth, 35*displaywidth) Font:16.0 Text:name Color:RGB(77, 77, 77)];
                [cell.contentView addSubview:titleLabel];
                if (_deatilType != 3)
                {
                    UIButton *gzBtn = [ZCControl createButtonWithFrame:CGRectMake(15*displaywidth, 0, SCREEN_WIDTH/2, 35*displaywidth) ImageName:nil Target:self Action:@selector(gzAction) Title:nil Font:12.0];
                    gzBtn.backgroundColor = [UIColor clearColor];
                    [cell.contentView addSubview:gzBtn];
                    if (_deatilType == 2 && _isWC)
                    {
                        NSString *raiseStr = @"立即评价";
                        UIColor *rabackColor = ThemeColor;
                        BOOL K = YES;
                        if ([_detailModel.employerEvaluated integerValue] == 1)
                        {
                            raiseStr = @"已评价";
                            rabackColor = RGB(179, 179, 179);
                            K = NO;
                        }
                        UIButton *raiseBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-80*displaywidth, 22.5*displaywidth, 70, 25*displaywidth) ImageName:nil Target:self Action:@selector(EmployeraiseAction) Title:raiseStr Font:12.0];
                        [raiseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        raiseBtn.layer.cornerRadius = 3;
                        raiseBtn.layer.masksToBounds = YES;
                        raiseBtn.backgroundColor = rabackColor;
                        raiseBtn.enabled = K;
                        [cell.contentView addSubview:raiseBtn];
                    }
                    
                }
                
                if (_deatilType == 3)
                {
                    UILabel *addressLabel = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 35*displaywidth, SCREEN_WIDTH- 85*displaywidth, 35*displaywidth) Font:16.0 Text:name Color:RGB(153, 153, 153)];
                    [cell.contentView addSubview:addressLabel];
                }
                else
                {
                    UIImageView *imgAview = [ZCControl createImageViewWithFrame:CGRectMake(15*displaywidth, 40*displaywidth, 20*displaywidth, 20*displaywidth) ImageName:@"gznr"];
                    imgAview.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.contentView addSubview:imgAview];
                    UILabel *nameLab = [ZCControl createLabelWithFrame:CGRectMake(40*displaywidth, 35*displaywidth, SCREEN_WIDTH-160*displaywidth, 30*displaywidth) Font:13.0 Text:_detailModel.categoryName Color:RGB(153, 153, 153)];
                    CGRect bounds = [nameLab.text boundingRectWithSize:CGSizeMake(1000, 30*displaywidth) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:NormalFontWithSize(13.0+fontScale) forKey:NSFontAttributeName] context:nil];
                    CGFloat W = bounds.size.width;
                    if (W > SCREEN_WIDTH-170*displaywidth)
                    {
                        W = SCREEN_WIDTH-170*displaywidth;
                    }
                    nameLab.frame = CGRectMake(40*displaywidth, 35*displaywidth, W+5*displaywidth, 30*displaywidth);
                    [cell.contentView addSubview:nameLab];
                    UIImageView *imgBview = [ZCControl createImageViewWithFrame:CGRectMake(W+60*displaywidth, 40*displaywidth, 20*displaywidth, 20*displaywidth) ImageName:@"xiangmujine"];//xiangmujine
                    imgBview.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.contentView addSubview:imgBview];
                    UILabel *moneyLab = [ZCControl createLabelWithFrame:CGRectMake(W+85*displaywidth, 35*displaywidth, 100*displaywidth, 30*displaywidth) Font:13.0 Text:[NSString stringWithFormat:@"%@",_detailModel.budget] Color:RGB(153, 153, 153)];
                    [cell.contentView addSubview:moneyLab];
                }
            }
            
            
        }
        else if (indexPath.section == 1)
        {
            UIView *lineBview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5*displaywidth)];
            lineBview.backgroundColor = BacksColor;
            [cell.contentView addSubview:lineBview];
            UILabel *titBlabel = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 5*displaywidth, 150*displaywidth, 39*displaywidth) Font:15.0 Text:@"岗位描述" Color:RGB(77, 77, 77)];
            [cell.contentView addSubview:titBlabel];
            UIView *lineCview = [[UIView alloc] initWithFrame:CGRectMake(15*displaywidth, 44*displaywidth, SCREEN_WIDTH, 1*displaywidth)];
            lineCview.backgroundColor = LinesColor;
            [cell.contentView addSubview:lineCview];
            UILabel *tostLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 45*displaywidth, SCREEN_WIDTH-30*displaywidth, 70*displaywidth) Font:13.0 Text:[NSString stringWithFormat:@"生产说明：\n%@",_detailModel.remark] Color:RGB(77, 77, 77)];
            tostLab.lineBreakMode = NSLineBreakByTruncatingTail;
            tostLab.adjustsFontSizeToFitWidth = NO;
            [cell.contentView addSubview:tostLab];
            
            UILabel *sbLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 115*displaywidth, 150*displaywidth, 25*displaywidth) Font:15.0 Text:@"生产设备：" Color:RGB(77, 77, 77)];
            [cell.contentView addSubview:sbLab];
            NSArray *sbAry = _detailModel.machines;
            CGFloat H = 140*displaywidth;
            if (sbAry.count > 0)
            {
                for (int i = 0; i < sbAry.count; i++)
                {
                    MachinesModel *macModel = sbAry[i];
                    UILabel *leftLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, H, 280*displaywidth, 20*displaywidth) Font:12.0 Text:macModel.machineName Color:RGB(153, 153, 153)];
                    [cell.contentView addSubview:leftLab];
                    UILabel *rightLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-130*displaywidth, H, 115*displaywidth, 20*displaywidth) Font:12.0 Text:[NSString stringWithFormat:@"%@台",macModel.count] Color:RGB(153, 153, 153)];
                    rightLab.textAlignment = NSTextAlignmentRight;
                    [cell.contentView addSubview:rightLab];
                    H+=20*displaywidth;
                }
            }
            H+=20*displaywidth;
            UILabel *numLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, H, 150*displaywidth, 25*displaywidth) Font:15.0 Text:@"所需工人" Color:RGB(77, 77, 77)];
            [cell.contentView addSubview:numLab];
            NSArray *groupAry = _detailModel.workGroups;
            H+=25*displaywidth;
            if (groupAry.count > 0)
            {
                for (int i = 0; i < groupAry.count; i++)
                {
                    WorkGroupsModel *gropModel = groupAry[i];
                    UILabel *leftLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, H, 280*displaywidth, 20*displaywidth) Font:12.0 Text:gropModel.workName Color:RGB(153, 153, 153)];
                    [cell.contentView addSubview:leftLab];
                    UILabel *rightLab = [ZCControl createLabelWithFrame:CGRectMake(SCREEN_WIDTH-130*displaywidth, H, 115*displaywidth, 20*displaywidth) Font:12.0 Text:[NSString stringWithFormat:@"%@人",gropModel.count] Color:RGB(153, 153, 153)];
                    rightLab.textAlignment = NSTextAlignmentRight;
                    [cell.contentView addSubview:rightLab];
                    H+=20*displaywidth;
                }
            }
//            H+=20*displaywidth;
            
        }
        else if (indexPath.section == 2)
        {
            UIView *lineDview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 5*displaywidth)];
            lineDview.backgroundColor = BacksColor;
            [cell.contentView addSubview:lineDview];
            UILabel *titBlabel = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 80*displaywidth, 150*displaywidth, 39*displaywidth) Font:15.0 Text:@"生产节点" Color:RGB(77, 77, 77)];
            [cell.contentView addSubview:titBlabel];
            UIView *lineEview = [[UIView alloc] initWithFrame:CGRectMake(15*displaywidth, 119*displaywidth, SCREEN_WIDTH, 1*displaywidth)];
            lineEview.backgroundColor = LinesColor;
            [cell.contentView addSubview:lineEview];
            if (_deatilType != 3)
            {
                NSString *sfType = @"厂家";
                NSString *name = _detailModel.contractor.user.name;
                UIColor *backColor = ThemeColor;
                UILabel *typeLab = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 15*displaywidth, 35*displaywidth, 15*displaywidth) Font:10.0 Text:sfType Color:[UIColor whiteColor]];
                typeLab.textAlignment = NSTextAlignmentCenter;
                typeLab.backgroundColor = backColor;
                typeLab.layer.cornerRadius = 2;
                typeLab.layer.masksToBounds = YES;
                [cell.contentView addSubview:typeLab];
                UILabel *titleLabel = [ZCControl createLabelWithFrame:CGRectMake(60*displaywidth, 5*displaywidth, SCREEN_WIDTH- 130*displaywidth, 35*displaywidth) Font:16.0 Text:name Color:RGB(77, 77, 77)];
                [cell.contentView addSubview:titleLabel];
                
                UILabel *addressLabel = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 40*displaywidth, SCREEN_WIDTH- 85*displaywidth, 34*displaywidth) Font:16.0 Text:name Color:RGB(153, 153, 153)];
                [cell.contentView addSubview:addressLabel];
                UIView *lineFview = [[UIView alloc] initWithFrame:CGRectMake(15*displaywidth, 74*displaywidth, SCREEN_WIDTH, 1*displaywidth)];
                lineFview.backgroundColor = LinesColor;
                [cell.contentView addSubview:lineFview];
                if (_deatilType == 2 && _isWC)
                {
                    NSString *raiseStr = @"立即评价";
                    UIColor *rabackColor = ThemeColor;
                    BOOL K = YES;
                    if ([_detailModel.contractorEvaluated integerValue] == 1)
                    {
                        raiseStr = @"已评价";
                        rabackColor = RGB(179, 179, 179);
                        K = NO;
                    }
                    UIButton *raiseBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-80*displaywidth, 27.5*displaywidth, 70, 25*displaywidth) ImageName:nil Target:self Action:@selector(contractorAction) Title:raiseStr Font:12.0];
                    [raiseBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                    raiseBtn.layer.cornerRadius = 3;
                    raiseBtn.layer.masksToBounds = YES;
                    raiseBtn.backgroundColor = rabackColor;
                    raiseBtn.enabled = K;
                    [cell.contentView addSubview:raiseBtn];
                }
                
            }
            else
            {
                titBlabel.frame = CGRectMake(15*displaywidth, 10*displaywidth, 150*displaywidth, 39*displaywidth);
                lineEview.frame = CGRectMake(15*displaywidth, 49*displaywidth, SCREEN_WIDTH, 1*displaywidth);
            }
        }
        else
        {
            SpotsModel *spoModel = _detailModel.spots[indexPath.row];
            if (indexPath.row == 0)
            {
                UIImageView *imgView = [ZCControl createImageViewWithFrame:CGRectMake(15*displaywidth, 10*displaywidth, 30*displaywidth, 30*displaywidth) ImageName:@"guanli"];
                imgView.layer.cornerRadius = 15*displaywidth;
                imgView.layer.masksToBounds = YES;
                [cell.contentView addSubview:imgView];
                
            }
            else
            {
                UILabel *label = [ZCControl createLabelWithFrame:CGRectMake(15*displaywidth, 10*displaywidth, 30*displaywidth, 30*displaywidth) Font:16.0 Text:[NSString stringWithFormat:@"%ld",indexPath.row] Color:[UIColor whiteColor]];
                label.textAlignment = NSTextAlignmentCenter;
                label.backgroundColor = RGB(236, 165, 84);
                label.layer.cornerRadius = 15*displaywidth;
                label.layer.masksToBounds = YES;
                [cell.contentView addSubview:label];
                
            }
            UILabel *bLabel = [ZCControl createLabelWithFrame:CGRectMake(60*displaywidth, 0, SCREEN_WIDTH- 130*displaywidth, 25*displaywidth) Font:14.0 Text:spoModel.remark  Color:RGB(77, 77, 77)];
            [cell.contentView addSubview:bLabel];
            NSString *nameStr = spoModel.workName;
            if (_deatilType != 1)
            {
                nameStr = spoModel.worker.user.name;
            }
            UILabel *nameLabel = [ZCControl createLabelWithFrame:CGRectMake(60*displaywidth, 25*displaywidth, SCREEN_WIDTH- 130*displaywidth, 25*displaywidth) Font:12.0 Text:nameStr Color:RGB(153, 153, 153)];
            [cell.contentView addSubview:nameLabel];
            if (_deatilType == 1)
            {
                NSInteger status = [spoModel.recommendStatus integerValue];
                NSString *titStr = @"报名参加";
                UIColor *baColor = ThemeColor;
                if (status == 1)
                {
                    titStr = @"已报名";
                    baColor = RGB(238, 103, 94);
                }
                else if (status == 2)
                {
                    titStr = @"已满员";
                    baColor = RGB(179, 179, 179);
                }
                UIButton *bmBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-95*displaywidth, 10*displaywidth, 80*displaywidth, 30*displaywidth) ImageName:nil Target:self Action:@selector(baomingAction:) Title:titStr Font:13.0];
                bmBtn.backgroundColor = baColor;
                bmBtn.tag = 200+indexPath.row;
                [bmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                bmBtn.layer.cornerRadius = 3;
                bmBtn.layer.masksToBounds = YES;
                [cell.contentView addSubview:bmBtn];
                if (status != 0)
                {
                    bmBtn.enabled = NO;
                }
            }
            else
            {
                UIButton *hoursBtn = [ZCControl createButtonWithFrame:CGRectMake(SCREEN_WIDTH-100*displaywidth, 5*displaywidth, 85*displaywidth, 40*displaywidth) ImageName:@"shizhong-" Target:nil Action:nil Title:[NSString stringWithFormat:@" %@小时",spoModel.hours] Font:12.0];
                [hoursBtn setTitleColor:RGB(77, 77, 77) forState:UIControlStateNormal];
                hoursBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
                hoursBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
                [cell.contentView addSubview:hoursBtn];
                if ([spoModel.worker.user.ID integerValue] == [[LTools cacheForKey:SERVER_UserID] integerValue])
                {
                    UIImageView *meImgView = [ZCControl createImageViewWithFrame:CGRectMake(SCREEN_WIDTH-40*displaywidth, 0, 40*displaywidth, 35*displaywidth) ImageName:@"wo"];
                    meImgView.backgroundColor = [UIColor clearColor];
                    meImgView.contentMode = UIViewContentModeScaleAspectFit;
                    [cell.contentView addSubview:meImgView];
                }
            }
            
        }
    }
   
    
    return cell;
}

//雇主信息
- (void)gzAction
{
    EmployerModel *model = _detailModel.employer;
    EmployerViewController *vc = [[EmployerViewController alloc] init];
    vc.empID = model.ID;
    [self.navigationController pushViewController:vc animated:YES];
    
}

//雇主评价
- (void)EmployeraiseAction
{
    AppraiseViewController *vc = [[AppraiseViewController alloc] init];
    vc.raiseID = _detailModel.employer.user.ID;
    vc.projectID = _projectID;
    [self.navigationController pushViewController:vc animated:YES];
}

//厂家评价
- (void)contractorAction
{
    AppraiseViewController *vc = [[AppraiseViewController alloc] init];
    vc.raiseID = _detailModel.contractor.user.ID;
    vc.projectID = _projectID;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}

- (void)baomingAction:(UIButton *)btn
{
    NSInteger index = btn.tag-200;
    NSArray *spotAry = _detailModel.spots;
    SpotsModel *model = spotAry[index];
    WEAKSELF;
    NSDictionary *dic = @{@"projectSpotId":[NSString stringWithFormat:@"%@",model.ID]};
    [HYBaseHandler requestRecommendAddParmers:dic Success:^(id obj) {
        if ([obj server_Getcodecheck])
        {
            [LTools showMBProgressWithText:@"报名成功" addToView:weakSelf.view];
            [weakSelf requestProjectSelect];
        }
        else
        {
            [LTools showMBProgressWithText:obj[@"msg"] addToView:weakSelf.view];
        }
    } failed:^(NSError *error) {
        
    }];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        if (_deatilType == 3)
        {
            return 70*displaywidth;
        }
        else
        {
            if (indexPath.row == 0)
            {
                return 50*displaywidth;
            }
            return 70*displaywidth;
        }
    }
    else if (indexPath.section == 1)
    {
        if (_detailModel)
        {
            CGFloat H = 140*displaywidth;
            NSArray *sbAry = _detailModel.machines;
            H += (sbAry.count*20*displaywidth);
            H+=45*displaywidth;
            NSArray *groupAry = _detailModel.workGroups;
            H += (groupAry.count*20*displaywidth);
            H += 20*displaywidth;
            return H;
        }
        return 1;
        

    }
    else if (indexPath.section == 2)
    {
        if (_deatilType == 3)
        {
            return 50*displaywidth;
        }
        return 120*displaywidth;
    }
    else if (indexPath.section == 3)
    {
        return 50*displaywidth;
    }
    return 100;
}


- (void)requestProjectSelect
{
    WEAKSELF;
    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:0];
    [dic setObject:[NSString stringWithFormat:@"%@",_projectID] forKey:@"id"];
    if (_deatilType == 1)
    {
        [dic setObject:@"1" forKey:@"recommendStatus"];
    }
    if (_deatilType == 2)
    {
        [dic setObject:@"1" forKey:@"queryEvaluate"];
    }
    [HYBaseHandler requestProjectSelectParmers:dic Success:^(id obj)
    {
        if ([obj server_Getcodecheck])
        {
            weakSelf.detailModel = [WorkerDetailModel mj_objectWithKeyValues:obj[@"data"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                [weakSelf.tableview reloadData];
            });
        }
        else
        {
            
        }
    } failed:^(NSError *error) {
        
    }];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
